﻿using System;
using System.Collections;
using System.Collections.Concurrent;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using log4net;
using static System.Net.Mime.MediaTypeNames;

namespace MotionCS.Helper
{
    public class Logger
    {
        public static void InitLog4Net()
        {
            string file = string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "logger.config");
            log4net.Config.XmlConfigurator.Configure(new FileInfo(file));
        }

        public static readonly ILog LogInfo = LogManager.GetLogger("MoveCtrlLog");

        //暂时不打印错误日志
        public static readonly ILog LogError = LogManager.GetLogger("ErrorLog");

        public static Action<string> LogCallback;

        public static void Logout(string text)
        {
            string tim = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff ");
            LogCallback?.BeginInvoke(tim + text,null,null);//-LZC log异步
            LogInfo.Debug(text);
        }

        public static void Logerr(string text)
        {
            LogCallback?.BeginInvoke(text,null,null);//-LZC log异步
            LogError.Debug(text);
        }
    }


}
